$(document).ready(function () {
	var content_h=$(window).height()-$(".g_hd").height()-4;
	$("#main_iframe").css("height",content_h+"px");
	$(".g_main ").css("height",content_h+"px");
    main.onload();
  
})

var main = (function () {

    var init = function () {
       $(window).resize(function(){
       	 main.windowResize();
       });
       layui.use('form', function () {
			var form = layui.form;
		});
		var cSname=commonJS.getQueryString("i");
		if(cSname=="gsgg"){
			 $("#main_iframe").attr("src", "ggfw/gsgg.html");
			 $(".m_nav li").find("a").removeClass("j_active");
			 $(".m_nav li").find("a[name=gzfw]").addClass("j_active");
		}else{
			 
		}
	    $(".m_nav li").each(function(){
	    	if($(this).find("a").attr("name")==cSname){
	    		var dataUrl = $(this).find("a").attr("data-url");
	    		$(this).siblings("li").find("a").removeClass("j_active");
	            $("#main_iframe").attr("src", dataUrl);
	            $(this).find("a").addClass("j_active");
	    	}
	    })
    }
    return {
        onload : function () {
            var curSeg = main;
            init();
            curSeg.hdTab();
		    curSeg.hdRight();
		    curSeg.windowResize();
		    curSeg.searchFocus();

	    // curSeg.onZxkf()

        },
        /*头部点击切换菜单*/
        hdTab:function(){
	       	$(".m_nav li").click(function(){
	       		var n=$(this).index();
				$(this).find("a").addClass("j_active");
				$(this).siblings("li").find("a").removeClass("j_active");
				var a_url=$(this).find("a").attr("data-url");
				$("#main_iframe").attr("src",a_url);
				if(n===3){
					$(".wxl_top_info_box").show();
					$(".g_hd").css("height","90px");
					var content_h=$(window).height()-$(".g_hd").height()-4;
		    		$("#main_iframe").css("height",content_h+"px");
				}else{
					$(".wxl_top_info_box").hide();
					$(".g_hd").css("height","60px");
					var content_h=$(window).height()-$(".g_hd").height()-4;
		    		$("#main_iframe").css("height",content_h+"px");
				}
			})
       },
       /*头部右侧鼠标经过显示*/
	    hdRight:function(){
	      	var timer = null;
			$(".m_icons_link>ul>li").hover(function(){
				$(this).siblings().find("div").hide();
				clearTimeout(timer);
				$(this).find("div").show();
				$(this).find("div").find('select').mouseleave(function(){return false;}); 
			},function(){
				var that = this;
				timer = setTimeout(function () {
					$(that).find("div").hide()
				},300)
			});
	    },
     /*页面放大缩小事件*/
	    windowResize:function(){
	    		var content_h=$(window).height()-$(".g_hd").height()-4;
		    	$("#main_iframe").css("height",content_h+"px");
				$(".g_main ").css("height",content_h+"px");

	    },
        //弹出显示
        onShow:function () {
            curSeg.onload();
		},
		onZxkf: function (msg, id) { //打开在线客服

			nsrsbh = jdglTools.getUserDataByKey("NSRSBH");
			shxydm = jdglTools.getUserDataByKey("SHXYDM");
			nsrmc = jdglTools.getUserDataByKey("NSRMC");
			msg = nsrmc + "(" + nsrsbh + ")" + "咨询在线客服";
			var a = $.base64('encode', encodeURI(sjly));
			var b = $.base64('encode', encodeURI(nsrsbh));
			var c = $.base64('encode', encodeURI(gnmk_mc));
			var d = $.base64('encode', encodeURI(cxxx));
			var e = $.base64('encode', encodeURI(shxydm));
			//获得窗口的垂直位置
			var iTop = (window.screen.availHeight - 30 - 620) / 2;
			//获得窗口的水平位置
			var iLeft = (window.screen.availWidth - 10 - 900) / 2;
			//判断时调用客户端版本的还是调用网页版本
			if (typeof external.Run_Fwzs != "undefined") {
				var dz = "sjly=" + a + "&nsrsbh=" + b + "&gnmk=" + c + "&cxxx=" + d;
				external.Run_Fwzs(dz);
			} else {
				var zxkfUrl = "http://218.28.172.26:20002/znkf/?sjly=" + a + "&nsrsbh=" + b + "," + e + "&gnmk=" + c + "&cxxx=" + d;
				window.open(zxkfUrl, '', 'height=650,innerHeight=620,width=1020,innerWidth=950,top=' + iTop + ',left=' + iLeft + ',status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=yes,titlebar=no');
			}

			//$(winObj.DOM.wrap).bgiframe();


		},
		/*搜索框聚焦*/
		searchFocus:function(){
			$("#titleInput").focus(function(){
				$(this).css('color','#666');
				$(this).parent().css('background','url(img/search_bg_focus.png) 0 0 no-repeat');
				$(this).next().find('i').css('color','#1092E8');
			})
			$("#titleInput").blur(function(){
				$(this).css('color','#fff');
				$(this).parent().css('background','url(img/search_bg.png) 0 0 no-repeat');
				$(this).next().find('i').css('color','#bce2ff');
			})
		}
    }
})();
